/**
 * PerFieldAnalyzerTest.java	1.0 2007 六月 13 17:09:10,创建
 */

package lia.ch4;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.lucene.analysis.PerFieldAnalyzerWrapper;
import org.apache.lucene.analysis.WhitespaceAnalyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.Query;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 *
 * @author 杨帆
 * @version 1.0 2007 六月 13 17:09:10,创建
 */
public class PerFieldAnalyzerTest
{
	@SuppressWarnings("unused")
	private static final Log log = LogFactory.getLog(PerFieldAnalyzerTest.class);

	@Before
	public void setUp() throws Exception
	{
	}

	@After
	public void tearDown() throws Exception
	{
	}

	@Test
	public void test1() throws Exception
	{
		try
		{
		PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(new StandardAnalyzer());
		analyzer.addAnalyzer("name", new WhitespaceAnalyzer());

		QueryParser parser = new QueryParser("age",analyzer);
		Query query = parser.parse("name:Q33 AND SPACE");
		log.debug(query);
		log.debug("-------");

//		AnalyzerDemo demo = new AnalyzerDemo();
//		demo.setAnalyzers(analyzer);
//		demo.setStrings("");
		}
		catch(Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
